package daily;

import java.util.Date;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class ThreadPoolTest {

	public static void main(String[] args) {
//		ExecutorService threadPool = Executors.newFixedThreadPool(3);
//		ExecutorService threadPool = Executors.newCachedThreadPool();
//		ExecutorService threadPool = Executors.newSingleThreadExecutor();
//		ExecutorService threadPool = Executors.newScheduledThreadPool(3);
//		for (int i = 0; i < 10; i++) {
//			final int count=i;
//			threadPool.execute(new Runnable() {
//				@Override
//				public void run() {
//					for (int k = 0; k < 3; k++) {
//					System.out.println(Thread.currentThread().getName() + 
//							" is loop of " + k + " for task " + count);
//					try {
//						Thread.sleep(1000);
//					} catch (InterruptedException e) {
//						e.printStackTrace();
//					}
//					}
//				}
//
//			});
//		}
		System.out.println("all task commited!");
//		threadPool.shutdown();
		
		Executors.newScheduledThreadPool(3).schedule(new Runnable(){

			@Override
			public void run() {
				System.out.println("A bombing!"+new Date());
			}
			
		}, 10, TimeUnit.SECONDS);
		
		Executors.newScheduledThreadPool(3).scheduleWithFixedDelay(new Runnable(){

			@Override
			public void run() {
				System.out.println("B bombing!"+new Date());
			}
			
		}, 5,3, TimeUnit.SECONDS);
		
		
	}

}
